<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link href="css/me.css" rel="stylesheet" />
	</head>
    <script src="js/mui.js"></script>
	<script type="text/javascript" src="js/app.js" ></script>
	<body>
		<div class="mui-content">
		<ul class="mui-table-view">
			<li class="mui-table-view-cell mui-media">
				<a id = "link_myface"href="javascript:;">
					<span class="mui-pull-right mui-icon mui-icon-arrowright me-min-cion"></span>
					<img id="img_myface" class="mui-media-object mui-pull-right" src="image/headimg.jpg">
					<div class="mui-media-body me-head-ziti">
						头像			
					</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media">
				<a id="link_nickname" href="javascript:;">
					<span class="mui-pull-right mui-icon mui-icon-arrowright me-min-cion"></span>
					<span id="spand_nickname" class="mui-pull-right me-nickname"></span>
					<div class="mui-media-body me-head-ziti">
						昵称
							
					</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;">
					<span id="spand_username" class="mui-pull-right me-nickname"></span>
					<div class="mui-media-body me-head-ziti">
					    账号					
					</div>
				</a>
			</li>
				<li class="mui-table-view-cell mui-media">
				<a id="link_qrcode" href="javascript:;">
					<span class="mui-pull-right mui-icon mui-icon-arrowright me-min-cion"></span>
					<img class="mui-media-object mui-pull-right me-twocode" src="image/qrcode.png">
					<div class="mui-media-body me-head-ziti">
					    我的二维码
					
					</div>
				</a>
			</li>
		</ul>
		</br>
		<ul class="mui-table-view">
			<li class="mui-table-view-cell mui-media" style="text-align: center;">
				<a id="link_logout" href="javascript:;">
					
					<div class="mui-media-body me-head-ziti">
					    退出登录				
					</div>
				</a>
			</li>
			</ul>
		
		</div>
		
		
		<script type="text/javascript">
			mui.init()
			mui.plusReady(function(){
				// 获取当前webview,刷新当前用户信息
				var meWebview = plus.webview.currentWebview();
				meWebview.addEventListener("show",function(){
					refreshUserInfo();
					
				});
				// 页面跳转，我的头像
				var link_myface = document.getElementById("link_myface");
				link_myface.addEventListener("tap", function() {
					mui.openWindow("myface.html", "myface.html");
				});
				
				
				
				// 添加自定义事件，刷新头像
				window.addEventListener("refresh", function(){
						refreshUserInfo();
					});
					
				// 页面跳转，修改昵称
				var link_nickname = document.getElementById("link_nickname");
				link_nickname.addEventListener("tap", function() {
					mui.openWindow("mynickname.html", "mynickname.html");
				});	
				// 页面跳转，我的二维码
				var link_nickname = document.getElementById("link_qrcode");
				link_nickname.addEventListener("tap", function() {
					mui.openWindow("myQRCode.html", "myQRCode.html");
				});
				// 页面跳转，退出登录
				var link_nickname = document.getElementById("link_logout");
				link_nickname.addEventListener("tap", function() {
					app.userLogout();
					mui.openWindow("login.html","login.html");
				});
			});
			
			function refreshUserInfo(){
			
				// 获取用户登录授权
				var user = app.getUserGlobalInfo();
				console.log(JSON.stringify(user))
				// console.log(user);
			
					if(user !=null){
					var faceImage = user.faceImage;
					var nickname = user.nickname;
					var username = user.username;
					// console.log(nickname);
					var spand_nickname = document.getElementById("spand_nickname");
					
					var spand_username = document.getElementById("spand_username");
					// console.log(spand_nickname)
					spand_nickname.innerHTML = nickname;
					spand_username.innerHTML = username;
					if(app.isNotNull(faceImage)){
					var img_myface = document.getElementById("img_myface");	
					console.log("测试1"+img_myface.src)
					img_myface.src = app.imgServerUrl+faceImage;
					console.log("测试2"+img_myface.src)
					}
					
					}
					
					
				
			}
		</script>
		
	</body>

</html>
